package cn.marinda.gui.impl;

import cn.marinda.gui.AbstractServerDialog;
import cn.marinda.listener.OpenServerConsoleActivityEvent;

import javax.swing.*;
import java.awt.*;
import java.util.List;

/**
 * 成功创建服务器对话框
 *
 * @author marinda
 * @date 2022/07/27
 */
public class SuccessSettingSelectCoreDialogImpl extends AbstractServerDialog {
    public static SuccessSettingSelectCoreDialogImpl instace = new SuccessSettingSelectCoreDialogImpl();
    /**
     * 成功创建服务器对话框
     */
    private SuccessSettingSelectCoreDialogImpl(){
        super();
    }


    @Override
    protected JDialog loadDialog() {
        dialog = new JDialog();
        dialog.setSize(400,100);
        dialog.setTitle("修改完毕");
        dialog.setLocationRelativeTo(null);
        dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        dialog.setResizable(false);
        dialog.setContentPane(view);
        return dialog;
    }

    @Override
    protected JPanel loadView() {
        view = new JPanel();
        componentList.stream().forEach(ele->{
            view.add(ele);
        });
        return view;
    }

    @Override
    protected List<JComponent> loadComponent() {
        JLabel textMessage = new JLabel("核心已经修改完毕，请点击确定前往服务器控制台！");
        textMessage.setFont(new Font(null,Font.PLAIN,14));
        textMessage.setForeground(Color.black);
        JButton successBtn = new JButton("成功");
        successBtn.setBorderPainted(false);
        successBtn.setFocusPainted(false);
        successBtn.setBackground(Color.RED);
        successBtn.setForeground(Color.BLACK);
        successBtn.addActionListener(new OpenServerConsoleActivityEvent(this));
        componentList.add(textMessage);
        componentList.add(successBtn);
        return componentList;
    }

    /**
     * 开放
     */
    @Override
    public void open() {
        dialog.setVisible(true);
    }

    /**
     * 关闭
     */
    @Override
    public void close() {
        dialog.setVisible(false);
    }
}
